﻿namespace Gunningine
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using log4net;
    using log4net.Core;

    public class Logger
    {
        private static Logger instance = null;

        private static object syncRoot = new object();

        private ILog log = null;

        private static Logger Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                            instance = new Logger();
                    }
                }

                return instance;
            }
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log"></param>
        private Logger()
        {
            if (this.log == null)
                this.log = LogManager.GetLogger("Main");
        }

        /// <summary>
        /// Log a debug message.
        /// </summary>
        /// <param name="message"></param>
        public static void Debug(string message)
        {
            Logger.Instance.log.Debug(message);
        }

        /// <summary>
        /// Log a debug message.
        /// </summary>
        /// <param name="message"></param>
        public static void DebugFormat(string message, params object[] args)
        {
            Logger.Instance.log.DebugFormat(message, args);
        }

        /// <summary>
        /// Log a message as info.
        /// </summary>
        /// <param name="message"></param>
        public static void Info(string message)
        {
            Logger.Instance.log.Info(message);
        }

        /// <summary>
        /// Log a message as info.
        /// </summary>
        /// <param name="message"></param>
        public static void InfoFormat(string message, params object[] args)
        {
            Logger.Instance.log.InfoFormat(message, args);
        }

        /// <summary>
        /// Log a message as a warning.
        /// </summary>
        /// <param name="message"></param>
        public static void Warn(string message)
        {
            Logger.Instance.log.Warn(message);
        }

        /// <summary>
        /// Log a message as a warning.
        /// </summary>
        /// <param name="message"></param>
        public static void WarnFormat(string message, params object[] args)
        {
            Logger.Instance.log.WarnFormat(message, args);
        }

        /// <summary>
        /// Log a message as an error.
        /// </summary>
        /// <param name="message"></param>
        public static void Error(string message)
        {
            Logger.Instance.log.Error(message);
        }

        /// <summary>
        /// Log a message as an error.
        /// </summary>
        /// <param name="message"></param>
        public static void ErrorFormat(string message, params object[] args)
        {
            Logger.Instance.log.ErrorFormat(message, args);
        }

        /// <summary>
        /// Log a message as a fatal error.
        /// </summary>
        /// <param name="message"></param>
        public static void Fatal(string message)
        {
            Logger.Instance.log.Fatal(message);
        }

        /// <summary>
        /// Log a message as a fatal error.
        /// </summary>
        /// <param name="message"></param>
        public static void FatalFormat(string message, params object[] args)
        {
            Logger.Instance.log.FatalFormat(message, args);
        }
    }
}
